package com.example.logisticsingle.Service;


import com.example.logisticsingle.Mapper.UserInfoMapper;
import com.example.logisticsingle.Mapper.UserRoleMapper;
import com.example.logisticsingle.String.StringUtils;
import com.example.logisticsingle.model.SystemUser;
import com.example.logisticsingle.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户服务实现类
 * @author Roskin
 *
 */
@Service
public class UserServiceImpl implements UserService {
	
	@Autowired
	//private SystemUserMapper systemUserMapper;
	private UserInfoMapper userInfoMapper;
	
	@Autowired
	private UserRoleMapper userRoleMappper;

	@Override
	public UserInfo findUserByUsername(String username) {
		return userInfoMapper.findUserByUsername(username);
	}

	@Override
	public SystemUser findUserByMobile(String mobile) {
		return null;
	}

	@Override
	public UserInfo updateUser(UserInfo user) {
		int count = userInfoMapper.updateByPrimaryKeySelective(user);
		if(count>0) return user;
		return null;
	}

	@Override
	public List<String> findUserRoles(String userId) {
		if(StringUtils.isNull(userId)) return null;
		return userRoleMappper.queryRoles(userId);
	}

}
